package com.coder520.user.service;

import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.coder520.common.utils.MD5Utils;
import com.coder520.user.dao.UserMapper;
import com.coder520.user.entity.User;
@Service("userServiceImpl")
public class UserServiceImpl implements UserService{
	@Autowired
	private UserMapper userMapper;
	
	@Override
	public User findUserByName(String username) {
		// TODO Auto-generated method stub
		User user=userMapper.selectByUserName(username);
		return user;
	}

	@Override
	public void createUser(User user) throws NoSuchAlgorithmException, UnsupportedEncodingException {
		// TODO Auto-generated method stub
		user.setPassword(MD5Utils.encrptyPassword(user.getPassword()));
		userMapper.insertSelective(user);
	}
	

}
